package com.sl.pmpclient.activities;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabWidget;

import com.sl.pmpclient.R;
import com.sl.pmpclient.activities.tabs.TabActivityActivity;
import com.sl.pmpclient.activities.tabs.TabBBSActivity;
import com.sl.pmpclient.activities.tabs.TabHomeActivity;
import com.sl.pmpclient.activities.tabs.TabSelfInfoActivity;
import com.sl.pmpclient.activities.tabs.TabTestActivity;

public class HomeActivity extends TabActivity implements OnTabChangeListener {
	private TabHost tabhost;
	private TabWidget tabcontent;

	private void init_guis() {
		// 取得tabhost
		this.tabhost = this.getTabHost();
		// 用于内容显示的intents
		Intent[] intents = new Intent[5];

		intents[0] = new Intent(this, TabHomeActivity.class);
		intents[1] = new Intent(this, TabTestActivity.class);
		intents[2] = new Intent(this, TabActivityActivity.class);
		intents[3] = new Intent(this, TabBBSActivity.class);
		intents[4] = new Intent(this, TabSelfInfoActivity.class);

		// 设置标签
		this.tabhost.addTab(this.tabhost
				.newTabSpec(getResources().getString(R.string.tab_home_str))
				.setIndicator(getResources().getString(R.string.tab_home_str),
						null).setContent(intents[0]));
		this.tabhost.addTab(this.tabhost
				.newTabSpec(getResources().getString(R.string.tab_test_str))
				.setIndicator(getResources().getString(R.string.tab_test_str),
						null).setContent(intents[1]));
		this.tabhost
				.addTab(this.tabhost
						.newTabSpec(
								getResources().getString(
										R.string.tab_activity_str))
						.setIndicator(
								getResources().getString(
										R.string.tab_activity_str), null)
						.setContent(intents[2]));
		this.tabhost.addTab(this.tabhost
				.newTabSpec(getResources().getString(R.string.tab_bbs_str))
				.setIndicator(getResources().getString(R.string.tab_bbs_str),
						null).setContent(intents[3]));
		this.tabhost
				.addTab(this.tabhost
						.newTabSpec(
								getResources().getString(
										R.string.tab_selfinfo_str))
						.setIndicator(
								getResources().getString(
										R.string.tab_selfinfo_str), null)
						.setContent(intents[4]));

		// 监听事件
		this.tabhost.setOnTabChangedListener(this);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.activity_home);
		this.init_guis();
	}

	@Override
	public void onCreateContextMenu(ContextMenu menu, View v,
			ContextMenuInfo menuInfo) {
		// TODO Auto-generated method stub
		super.onCreateContextMenu(menu, v, menuInfo);
	}

	@Override
	public void onTabChanged(String tabId) {
		// TODO Auto-generated method stub

	}

}
